const program = require('commander')
const { createAction, createCpnAction, addPageAction } = require('./actions')

// 创建命令 mal create 等
const createCommands = () => {
  const options = program.opts()

  program
    .command('create <project> [others...]')
    .description('helps you clone template from gitee to localtion')
    .action(createAction)

  program
    .command('addcpn <componentName> [others...]')
    .description('create vue component, eg: mal addcpn Demo <-d src/Demo>')
    .action((componentName) => {
      createCpnAction(componentName, options.dest || './src/components')
    })

  program
    .command('addpage <pageName>')
    .description('create page, eg: mal addpage TestPage [-d ./src/page]')
    .action((pageName) => {
      addPageAction(pageName, options.dest || './src/page', options.lang || 'ts')
    })

}

module.exports = createCommands
